import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Creat with IntelliJ IDEA
 * Description:
 * User:WZW
 * Date:2022-08-10
 * Time:18:38
 */
public class App {
    public static void main(String[] args) {
        //1.先得到上下文对象
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
        //2.得到bean
        UserController controller = context.getBean("userController",UserController.class);//默认小驼峰命名
        UserService service = context.getBean("userService", UserService.class);//默认小驼峰命名
        UserRepository repository = context.getBean("userRepository",UserRepository.class);
        UseConfiguration configuration = context.getBean("useConfiguration",UseConfiguration.class);
        UserComponent component = context.getBean("userComponent",UserComponent.class);

        User user = context.getBean("user",User.class);
        //3.使用bean
        controller.sayHi();
        service.sayHi();
        repository.sayHi();
        configuration.sayHi();
        component.sayHi();
        System.out.println(user.toString());
    }
}
